VERSION 5.00
Begin VB.UserControl Framez 
   Appearance      =   0  'Flat
   AutoRedraw      =   -1  'True
   BackColor       =   &H80000005&
   ClientHeight    =   780
   ClientLeft      =   0
   ClientTop       =   0
   ClientWidth     =   1515
   ControlContainer=   -1  'True
   BeginProperty Font 
      Name            =   "Courier New"
      Size            =   9.75
      Charset         =   0
      Weight          =   400
      Underline       =   0   'False
      Italic          =   0   'False
      Strikethrough   =   0   'False
   EndProperty
   LockControls    =   -1  'True
   ScaleHeight     =   52
   ScaleMode       =   3  'Pixel
   ScaleWidth      =   101
End
Attribute VB_Name = "Framez"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = False
Option Explicit

Private Type RECT
    Left    As Long
    Top     As Long
    Right   As Long
    Bottom  As Long
End Type

Private Const DT_SINGLELINE = &H20
Private Declare Function DrawText Lib "user32.dll" Alias "DrawTextA" (ByVal hdc As Long, ByVal lpStr As String, ByVal nCount As Long, ByRef lpRect As RECT, ByVal wFormat As Long) As Long
Private Declare Function BitBlt Lib "gdi32" (ByVal hdcDest As Long, ByVal xDest As Long, ByVal yDest As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal hdcSrc As Long, ByVal xSrc As Long, ByVal ySrc As Long, ByVal dwRop As Long) As Long
Private Declare Function DrawEdge Lib "user32" (ByVal hdc As Long, qrc As RECT, ByVal edge As Long, ByVal grfFlags As Long) As Long

Public Enum FBorder
    RaisedOut = 1
    SunkenOut = 2
    RaisedIn = 4
    SunkenIn = 8
    EtchedOut = RaisedOut Or SunkenIn
    EtchedIn = SunkenOut Or RaisedIn
    Button = RaisedIn Or RaisedOut
    Control = SunkenIn Or SunkenOut
    None = Button Or Control
End Enum

Private mForeColor          As OLE_COLOR
Private mForeColorDisabled  As OLE_COLOR
Private mBorder             As FBorder
Private mCaption            As String
Private mEnabled            As Boolean

Public Property Let Caption(ByVal NewValue As String)
    mCaption = NewValue
    ReDraw
    PropertyChanged "Caption"
End Property

Public Property Get Caption() As String
Attribute Caption.VB_UserMemId = -518
    Caption = mCaption
End Property

Public Property Let ForeColor(ByVal NewVal As OLE_COLOR)
     mForeColor = NewVal
     ReDraw
     PropertyChanged "ForeColor"
End Property

Public Property Get ForeColor() As OLE_COLOR
     ForeColor = mForeColor
End Property

Public Property Get Font() As Font
    Set Font = UserControl.Font
End Property

Public Sub ReDraw()
    Dim rc  As RECT
    On Error GoTo ErrorHandler
    ' clear background
    UserControl.Cls
    If mBorder = Control Then
    Dim i%
        For i = 0 To 2
            PaintPicture ImagenFromBits(LoadResData("FRME", "FONDO")), i * 881, 0
        Next
    Else
        ' copy parent background
        pvMakeTransparent
    End If
    Exit Sub
    UserControl.Refresh
ErrorHandler:
End Sub

Public Property Get Enabled() As Boolean
    Enabled = mEnabled
End Property

Public Property Let Enabled(ByVal NewVal As Boolean)
    mEnabled = NewVal
    ' If in design don't set Enabled  property
    If UserControl.Ambient.UserMode = True Then UserControl.Enabled = NewVal
    ReDraw
    PropertyChanged "Enabled"
End Property

Private Sub pvMakeTransparent()
    ' //Make UC appear transparent //
    On Error GoTo ErrorHandler
    With UserControl.Extender.Container
        .AutoRedraw = True
        BitBlt UserControl.hdc, 0, 0, _
            .ScaleX(UserControl.Width, .ScaleMode, vbPixels), _
            .ScaleY(UserControl.Height, .ScaleMode, vbPixels), _
            .hdc, _
            .ScaleX(UserControl.Extender.Left, .ScaleMode, vbPixels), _
            .ScaleY(UserControl.Extender.Top, .ScaleMode, vbPixels), _
            vbSrcCopy
    End With
    Exit Sub
ErrorHandler:
End Sub

Public Property Let FrameStyle(ByVal NewValue As FBorder)
     mBorder = NewValue
     ReDraw
     PropertyChanged "FrameStyle"
End Property

Public Property Get FrameStyle() As FBorder
    FrameStyle = mBorder
End Property

Public Property Set Font(ByVal value As Font)
    Set UserControl.Font = value
    PropertyChanged "Font"
    ReDraw
End Property

Private Sub UserControl_Initialize()
    mBorder = None
    mForeColorDisabled = &H808080
    mEnabled = True
End Sub

Private Sub UserControl_InitProperties()
    Caption = Extender.Name
End Sub

Private Sub UserControl_ReadProperties(PropBag As PropertyBag)
    With PropBag
        Set UserControl.Font = .ReadProperty("Font", Ambient.Font)
        ForeColor = .ReadProperty("ForeColor", vbBlack)
        ForeColorDisabled = .ReadProperty("ForeColorDisabled", &H808080)
        FrameStyle = .ReadProperty("FrameStyle", FBorder.None)
        Caption = .ReadProperty("Caption", "")
        Enabled = .ReadProperty("Enabled", True)
    End With
End Sub

Private Sub UserControl_Resize()
    ReDraw
End Sub

Private Sub UserControl_WriteProperties(PropBag As PropertyBag)
    With PropBag
        .WriteProperty "Font", UserControl.Font, Ambient.Font
        .WriteProperty "ForeColor", mForeColor, vbBlack
        .WriteProperty "ForeColorDisabled", mForeColorDisabled, &H808080
        .WriteProperty "FrameStyle", mBorder, ""
        .WriteProperty "Caption", mCaption, ""
        .WriteProperty "Enabled", mEnabled, True
    End With
End Sub

Public Property Let ForeColorDisabled(ByVal NewVal As OLE_COLOR)
     mForeColorDisabled = NewVal
     ReDraw
     PropertyChanged "ForeColorDisabled"
End Property

Public Property Get ForeColorDisabled() As OLE_COLOR
     ForeColorDisabled = mForeColorDisabled
End Property

'ADVERTENCIA: NO QUITAR NI MODIFICAR LAS SIGUIENTES LINEAS CON COMENTARIOS
'MappingInfo=UserControl,UserControl,-1,Refresh
Public Sub Refresh()
    UserControl.Refresh
End Sub

